//
//  LHRecommendSightTableViewCell.m
//  Knight_Tour
//
//  Created by 庞魁 on 15-5-14.
//  Copyright (c) 2015年 TouchOne. All rights reserved.
//

#import "LHRecommendSightTableViewCell.h"
#import "UIImageView+WebCache.h"

@interface LHRecommendSightTableViewCell ()

@property (nonatomic, retain) UILabel *sightName;
@property (nonatomic, retain) UIImageView *sightPicture;
@property (nonatomic, retain) UILabel *sightAddress;
@property (nonatomic, retain) UILabel *sightOpenTime;
@property (nonatomic, retain) UILabel *sightRecommendReson;
@property (nonatomic, retain) UIImageView *sightLevel;


@end

@implementation LHRecommendSightTableViewCell

- (void)dealloc
{
    [_sightName release];
    [_sightPicture release];
    [_sightAddress release];
    [_sightOpenTime release];
    [_sightRecommendReson release];
    [_sightLevel release];
    [super dealloc];
    
}

/**
 *  重写初始化
 */

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.sightName = [[UILabel alloc] init];
        
        [self.contentView addSubview:_sightName];
        
        [_sightName release];
        
        
        self.sightPicture = [[UIImageView alloc] init];
        
        [self.contentView addSubview:_sightPicture];
        
        self.sightPicture.layer.cornerRadius = 7;
        self.sightPicture.clipsToBounds = YES;
        
        [_sightPicture release];
        
        
        self.sightAddress = [[UILabel alloc] init];
        
        [self.contentView addSubview:_sightAddress];
        
        _sightAddress.numberOfLines = 2;
        
        [_sightAddress release];
        
        
        self.sightLevel = [[UIImageView alloc] init];
        
        [self.contentView addSubview:_sightLevel];
        
//        _sightLevel.backgroundColor = [UIColor colorWithRed:0.099 green:0.760 blue:0.974 alpha:1.000];
        
        [_sightLevel release];
        
        
        self.sightOpenTime = [[UILabel alloc] init];
        
        _sightOpenTime.numberOfLines = 2;
        
        [self.contentView addSubview:_sightOpenTime];
        
        
        
        
        self.sightRecommendReson = [[UILabel alloc] init];
        
        [self.contentView addSubview:_sightRecommendReson];
        
        _sightRecommendReson.numberOfLines = 3;
        
        [_sightRecommendReson release];
        
        

        
    }
    
    return self;
}

/**
 *  设置自定义cell的布局信息
 */
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _sightName.frame = CGRectMake(10, 10, 160, 30);
    
    _sightPicture.frame = CGRectMake(10, _sightName.frame.origin.y + 35, self.frame.size.width / 3, self.frame.size.width / 3);
    
    _sightOpenTime.frame = CGRectMake(_sightPicture.frame.origin.x + self.frame.size.width / 3 + 20, _sightPicture.frame.origin.y , 170, 40);
    
    _sightLevel.frame = CGRectMake(_sightPicture.frame.origin.x + self.frame.size.width / 3 + 20, _sightOpenTime.frame.origin.y + self.frame.size.width / 10 - 10, 60, 50);
    
    _sightAddress.frame = CGRectMake(_sightPicture.frame.origin.x + self.frame.size.width / 3 + 20, _sightLevel.frame.origin.y + self.frame.size.width / 10, 180, 40);
    
    _sightRecommendReson.frame = CGRectMake(20, _sightPicture.frame.origin.y + self.frame.size.width / 3, 300, 40);
    
    

}

// 重写setter方法
- (void)setReSightModel:(LHRecommendSightModel *)reSightModel
{
    if (_reSightModel != reSightModel) {
        
        [_reSightModel release];
        _reSightModel = [reSightModel retain];
    }
    
    _sightName.text = reSightModel.name;
    [_sightName setFont:[UIFont fontWithName:@"Helvetica-Bold" size:16]];
    
    [_sightPicture sd_setImageWithURL:[NSURL URLWithString:reSightModel.cover_s] placeholderImage:[UIImage imageNamed:@"word4"]];
    
    _sightAddress.text = reSightModel.address;
    [_sightAddress setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
    
    _sightOpenTime.text = reSightModel.opening_time;
    [_sightOpenTime setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
    
    _sightRecommendReson.text = reSightModel.recommended_reason;
    [_sightRecommendReson setFont:[UIFont fontWithName:@"Helvetica-Bold" size:13]];
    
    _sightLevel.image = [UIImage imageNamed:@"xingji"];
    
}




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
